/**
 * Created by sunyxq on 16/3/29.
 */
angular.module('hyt.findXianLuCtrl',[])

    .controller('XlListCtrl',function($scope,XlListFactory,Storage,$stateParams){
        var sid=Storage.get('sid');
        var user_id=Storage.get('user_id');
        var yh_id=Storage.get('yh_id');
        $scope.showloading = true;
        XlListFactory.getXlList(sid,user_id,yh_id,$stateParams.xlmc);
        $scope.$on('XlList.listUpdate',function(){
            var xlFactory=XlListFactory.getXl();
            $scope.xlData = xlFactory.data;
            console.log(xlFactory.data);
            $scope.showloading = false;
        });

        $scope.doRefresh = function(){
            XlListFactory.getXlList(sid,user_id,yh_id,$stateParams.xlmc);
            $scope.$broadcast('scroll.refreshComplete');
        }

        $scope.loadMore = function(){
            XlListFactory.getMoreXl(sid,user_id,yh_id,$stateParams.xlmc);
            $scope.$broadcast('scroll.infiniteScrollComplete');
        }

        $scope.hasNextPage = function(){
            return XlListFactory.hasNextPage();
        }

    })

    .controller('XlSearchCtrl',function($scope,$state){
        $scope.Search=function(xlmc){
            $state.go('xllist',{xlmc:xlmc});
        }
    })
